package io.nio;

import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @author lcx
 *
 */
public class FileNIO {

	public static void main(String[] args) throws IOException {
		FileInputStream fis=new FileInputStream("ByteTest.java");
		FileChannel  inChannel=fis.getChannel();
		ByteBuffer buffer=ByteBuffer.allocate(10);
		int bytesRead;
	   while((bytesRead=inChannel.read(buffer))>0)
		{
		System.out.println(new String(buffer.array(),0,bytesRead));
		buffer.clear();
		}
	}
}
